package com.juc.scheduledExecutorService.scheduledExecutorService3;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

public class Run {

	//延迟运行并取得返回值
	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws InterruptedException, ExecutionException {
		List<Callable> callableList = new ArrayList<Callable>();
		callableList.add(new MyCallableA());
		ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
		System.out.println("     X= " + System.currentTimeMillis());
		ScheduledFuture<String> futureA = executorService.schedule(callableList.get(0),4L , TimeUnit.SECONDS);
		System.out.println(futureA.get() + "  A =" +System.currentTimeMillis());
	}
}
